Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check team ID format at plan #253

Merged
merged 2 commits into from
Jul 16, 2019
Merged

Check team ID format at plan #253

merged 2 commits into from
Jul 16, 2019

Conversation

tgermain
Copy link
Contributor

@tgermain tgermain commented Jul 4, 2019

Hi,

I stumble on a bug while authorizing team on a repository using github_team_repository.

The faulty code was something like :

resource "github_team_repository" "some_team_repo" {
  team_id    = "github_team.some_team.id"
  repository = "${github_repository.some_repo.name}"
  permission = "pull"
}

Simple bug : I forgot to interpolate github_team.some_team.id so the provider get the string github_team.some_team.id instead of a proper team ID.

It fails at apply with Unexpected ID format ("github_team.some_team.id"), expected numerical ID. strconv.ParseInt: parsing "github_team.some_team.id": invalid syntax

I think it's a kind of error you can catch at plan time easily.

This PR introduce a validation of team_id on the two resource using it as parameters : github_team_repository and github_team_membership.
It is a very basic check function that :

  • try to cast the value as a string
  • try to convert the string to an int

I tried the github provider on my faulty code it detects the error at plan time as expected.

@ghost ghost added the size/S label Jul 4, 2019
Copy link
Contributor

@tracypholmes tracypholmes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @tgermain! Thank you for submitting this PR. LGTM 🎉

@tracypholmes tracypholmes merged commit bcd632e into integrations:master Jul 16, 2019
tracypholmes added a commit that referenced this pull request Jul 16, 2019
kfcampbell pushed a commit to kfcampbell/terraform-provider-github that referenced this pull request Jul 26, 2022
* Add validateTeamIDFunc function

* Add validation of teamID at plan time
kfcampbell pushed a commit to kfcampbell/terraform-provider-github that referenced this pull request Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants